import { service, service2 } from './request'

// 获取主页的数据-轮播
export const getBanners = () => {
  return service({
    url: '/api/home/photo',
    method: 'get'
  }).then(res => {
    return res.list
  })
}

// 获取商品推荐的数据
export const getList = (page = 1) => {
  const pageSize = 20
  const start = pageSize * (page - 1)
  let api = ''
  if (page === 1) {
    api = '/api/tab/1?start=0'
  } else {
    api = `/api/tab/1/feeds?start=${start}&sort=0`
  }
  return service2({
    url: api,
    method: 'get'
  }).then(res => {
    if (res.items) {
      return res.items.list
    }
    return res.list
  })
}
